Repository navigation
ENH: Add itk::MakeGraft and use it for mini-pipeline grafts - #7246
Conversation
dzenanz
left a comment
There was a problem hiding this comment.
Mostly looks good on a glance. I have not looked at the tests.
d5779d2 to
6a65cd0
Compare
Filters that run a mini-pipeline give it a graft of their input, so that the internal filters cannot release or rewire the real one. MakeGraft names that idiom at namespace scope. It takes a const pointer or a SmartPointer, so callers need no const_cast, returns null for null, and documents that the graft has no source. Closes InsightSoftwareConsortium#7243.
Replace each hand-written New() and Graft() pair, about 40 sites, with MakeGraft, which also drops the const_casts the old form used. Remove the protected ImageRegistrationMethodv4::MakeGraft (from InsightSoftwareConsortium#7095, in no release) and the private N4BiasFieldCorrectionImageFilter::MakeInputView (from InsightSoftwareConsortium#7093), and update the mini-pipeline example in the ImageSource documentation. The GPU discrete Gaussian filter grafts into a different image type and InvertDisplacementFieldImageFilter re-grafts the same objects each iteration, so both keep their explicit Graft() calls.
|
Two force-pushes: the first ( |
6a65cd0 to
aa727d4
Compare
[Medium impact] The PR appears safe to merge; no actionable issues were found.
|
Add
itk::MakeGraft(data), a namespace-scope helper that grafts a data object for use as a mini-pipeline input, and use it at the hand-written sites (about 40) and in place of two class-local copies (the protectedImageRegistrationMethodv4::MakeGraftfrom #7095 and the privateN4BiasFieldCorrectionImageFilter::MakeInputViewfrom #7093). Closes #7243; a follow-up to #7093.Merge danger: two-way door; additive API, behavior unchanged. The removed protected member is in no release.
Shape of the change
ENH) adds the helper anditkMakeGraftGTest.cxx. Commit 2 (STYLE) converts the sites, including the output grafts in the Canny edge detection and Hough circles filters,, which also drops theconst_casts the old form used, and updates the mini-pipeline example in theImageSource.hdocumentation.itkGPUDiscreteGaussianImageFilter.hxxgrafts into a different image type, anditkInvertDisplacementFieldImageFilter.hxxre-grafts the same two objects every iteration (PERF: Reuse one composer across InvertDisplacementField iterations #7212), whichMakeGraftcannot express.ImageRegistrationMethodv4member, so its callers see no change.Evidence
Local build,
/Users/johnsonhj/src/ITK-build-test-tree/build-makegraft(Release, Homebrew clang; default modules plus IsotropicWavelets, ParabolicMorphology, TextureFeatures, Thickness3D, StructuralSimilarity, and ITKSuperPixel):itkRieszRotationMatrix.h:199,-Wreturn-stack-address).ctest -R MakeGraft: 6/6 pass, including a check that a graft of a filter output has no source.pre-commit run --all-filespasses.Not built: GPU modules (
ITK_USE_GPU=OFF).AI assistance